package com.shiwaixiangcun.authz.oauth.token;

import com.shiwaixiangcun.authz.oauth.OAuthTokenxRequest;
import com.shiwaixiangcun.authz.oauth.validator.AbstractClientDetailsValidator;
import com.shiwaixiangcun.authz.oauth.validator.DynamicPasswordClientDetailsValidator;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 短息验证码登录  grantType=dynamic_password
 * <p>
 * Created by Administrator on 2017/5/19.
 */
public class DynamicPasswordTokenHandler extends PasswordTokenHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(PasswordTokenHandler.class);

    public static final String DYNAMIC_PASSWORD_GRANT_TYPE = "dynamic_password";


    @Override
    public boolean support(OAuthTokenxRequest tokenRequest) throws OAuthProblemException {
        final String grantType = tokenRequest.getGrantType();
        return DYNAMIC_PASSWORD_GRANT_TYPE.equalsIgnoreCase(grantType);
    }

    @Override
    protected AbstractClientDetailsValidator getValidator() {
        return new DynamicPasswordClientDetailsValidator(tokenRequest);
    }

}
